package week03;

public class T027 {
	
	public static boolean isPrime(int n) {
		if(n<=1) return false;
		for(int i=2;i*i<=n;i++) {
			if(n%i==0) return false;
		}
		return true;
	}
	
	public static int num(int a,int b) {
		int m=0;
		for(int i=0;i<1000;i++) {
			if(isPrime(i*i+a*i+b)) m++;
			else break;
		}
		return m;
	}
	
	public static void run() {
		int max=0,fa=0,fb=0;
		for(int i=-999;i<1000;i+=2) {
			for(int j=3;j<1000;j+=2) {
				int len=num(i, j);
				if(len>max) {
					max=len;
					fa=i;
					fb=j;
				}
			}
		}
		System.out.println(fa*fb);
	}
	public static void main(String[] args) {
		run();
	}

}
